package com.pkx.cloud.fse7.expand.group.controller;

import com.pkx.cloud.fse7.expand.group.entity.DoorGroup;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.cloud.fse7.expand.group.entity.DoorGroupDetail;
import com.pkx.cloud.fse7.expand.group.service.DoorGroupDetailService;
import com.pkx.cloud.whzx.comn.ORpose;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 控制器
 *
 * @author chenwg
 * @since 2021-04-09
 */
@RestController
@RequestMapping("/group/door-group-detail")
@Api(value = "门禁分组详情", tags = "门禁分组详情")
@Slf4j
@ORpose
public class DoorGroupDetailController {

    @Autowired
    private DoorGroupDetailService doorGroupDetailService;

    @ApiOperation("分页列表")
    @GetMapping("/page")
    public Page<DoorGroupDetail> page(Page page, DoorGroupDetail doorGroupDetail) {
        return doorGroupDetailService.pageList(page, doorGroupDetail);
    }

    @ApiOperation("列表")
    @GetMapping("/list")
    public List<DoorGroupDetail> list(DoorGroupDetail doorGroupDetail) {
        return doorGroupDetailService.listByEntity(doorGroupDetail);
    }

    @ApiOperation("详情")
    @GetMapping(value = "/{id}")
    public DoorGroupDetail selectById(@PathVariable("id") String id) {
        return doorGroupDetailService.selectById(id);
    }

    @ApiOperation("新增")
    @PostMapping("")
    public Boolean add(@RequestBody DoorGroupDetail doorGroupDetail) {
        return doorGroupDetailService.saveDoorGroupDetail(doorGroupDetail);
    }

    @ApiOperation("修改")
    @PutMapping("")
    public Boolean modify(@RequestBody DoorGroupDetail doorGroupDetail) {
        return doorGroupDetailService.modify(doorGroupDetail);
    }

    @ApiOperation("删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    public Boolean deleteById(@PathVariable("id") String id) {
        return doorGroupDetailService.deleteById(id);
    }

    @ApiOperation("分组设备列表")
    @GetMapping(value = "/getGroupDetailByPath")
    public Page<List<Map<String, Object>>> getGroupDetailByPath(Page page, DoorGroup doorGroup) {
        return doorGroupDetailService.getGroupDetailByPath(page, doorGroup);
    }

    @ApiOperation("或者分组下的设备列表名称")
    @GetMapping(value = "/listDevice/{groupId}")
    public List<String> listDevice(@PathVariable(value = "groupId") String groupId) {
        return doorGroupDetailService.listDevice(groupId);
    }
}
